<?php

    namespace yaliSDK\db;

    /**
     * Created by PhpStorm.
     * User: fang
     * Date: 2018/1/9
     * Time: 上午9:32
     */
    class TPDBResult implements IDBResult {
        private $data;

        public function __construct($data = '') {
            $this->data = $data;
        }

        /**
         * @return array
         * 获取数据的数组格式
         */
        public function getArray(): array {
            // TODO: Implement getArray() method.
            if (is_array($this->data)) return $this->data;
            if (!empty($this->data)) return (array)$this->data;
            return [];
        }

        /**
         * @return bool
         * 返回数据的bool格式
         */
        public function getBool(): bool {
            // TODO: Implement getBool() method.
            if (is_bool($this->data)) return $this->data;
            if (!empty($this->data)) return (bool)$this->data;
            return false;
        }

        public function getInt(): int {
            if (is_integer($this->data)) return $this->data;
            if (!empty($this->data)) return (int)$this->data;
            return 0;
        }

        public function getSting(): string {
            if (is_string($this->data)) return $this->data;
            if (!empty($this->data)) return (string)$this->data;
            return 0;
        }

        public function getData() {
            return $this->data;
        }
    }